package com.xiaogao.statistics.controller;


import com.xiaogao.commonUtils.Result;
import com.xiaogao.statistics.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author 小高
 * @since 2021-07-10
 */
@RestController
@RequestMapping("/statistics/daily")
//@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService dailyService;

    // 统计某一天注册人数,生成统计数据
    @PostMapping("/createStatisticsByDate/{day}")
    public Result createStatisticsByDate(@PathVariable String day){
        dailyService.createStatisticsByDay(day);
        return Result.ok();
    }

    // 图标显示,返回日期json数组,数量json数组
    @GetMapping("/showChart/{begin}/{end}/{type}")
    public Result showChart(
            @PathVariable String begin,
            @PathVariable String end,
            @PathVariable String type){
        Map<String,Object> map = dailyService.getChartData(begin,end,type);
        return Result.ok().data(map);
    }

}

